package com.huangsm.book.designmodel.jdkobserver;

import java.nio.Buffer;
import java.util.Observer;

/**
 * @author huang
 * @PACKAGE_NAME com.huangsm.book.designmodel.jdkobserver
 * @PROJECT_NAME concurrence
 * @date 2019/2/15
 */
public class Test {
    public static void main(String[] args) {
        //观察者对象
        Observer observer = new ConcreteObserver();
        Observer observer2 = new ConcreteObserver();
        Observer observer3 = new ConcreteObserver();

        //主体对象
        ConcreteSubject observable = new ConcreteSubject();

        //观察者加入主题对象汇总的观察者列表
        observable.addObserver(observer);
        observable.addObserver(observer2);
        observable.addObserver(observer3);

        //主体对象发生改变
        observable.doSomething("happy");
        observable.doSomething("sad");
    }
}
